/**
* Created by wl
* 基金储备库-基金信息
*/
<template>
    <div class="ca-p-20">
        <div v-if="!showEdit">
            <div class="ca-title">
                <h3>基金信息</h3>
                <el-button type="text"  class="ca-edit-btn el-icon-edit ca-right" @click="showEdit = true" :disabled="!isAuthEditPre" v-if="$route.name.includes('pre-investment-funds')">编辑</el-button>
                <el-button type="text" class="ca-edit-btn el-icon-edit ca-right" @click="showEdit=true" :disabled="!isAuthEdit" v-else>编辑</el-button>
            </div>
            <el-form label-width="180px" :model="fundReserveInfo">
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="投资方向：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.investmentDirection}}
                        </el-form-item>
                        <el-form-item label="基金来源：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.source}}
                        </el-form-item>
                        <el-form-item label="组织形式：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.organizationalForm | getNameById('fundForm')}}
                        </el-form-item>
                        <el-form-item label="办公地址：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{registrationDetailed2}}
                        </el-form-item>
                    </el-col>
                    <el-col :span="11">
                        <el-form-item label="投资阶段：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.investmentStage}}
                        </el-form-item>
                        <el-form-item label="管理费（%）：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            <span v-if="fundReserveInfo.expense">
                                {{fundReserveInfo.expense | format1}}
                            </span>
                        </el-form-item>
                        <el-form-item label="注册地址：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{registrationDetailed1}}
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span='22'>
                        <el-form-item label="投资地域：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.region}}
                        </el-form-item>
                        <el-form-item label="收益分配：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.distribution}}
                        </el-form-item>
                        <el-form-item label="设立背景：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.background}}
                        </el-form-item>
                        <el-form-item label="行业分析：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.analysis}}
                        </el-form-item>
                        <el-form-item label="项目遴选：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.projectSelection}}
                        </el-form-item>
                        <el-form-item label="投资决策：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.decision}}
                        </el-form-item>
                        <el-form-item label="激励约束：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.excitation}}
                        </el-form-item>
                        <el-form-item label="跟进投资：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.followOn}}
                        </el-form-item>
                        <el-form-item label="资产托管：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.trusteeship}}
                        </el-form-item>
                        <el-form-item label="风险控制：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.risk}}
                        </el-form-item>
                        <el-form-item label="业绩报酬：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.achievement}}
                        </el-form-item>
                        <el-form-item label="其他：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{fundReserveInfo.other}}
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
        <csFundInfo v-else @close="showEdit = false" @update="save()"></csFundInfo>
    </div>
</template>
<script type="text/ecmascript-6">
    import {api} from '../../api';
    import {STATUS_HTTP_SUCCESS, apiHttp} from '__service/csHttp';
    import { addRemind, isNoAuth } from '__service/utils';
    export default {
        data() {
            return {
                showEdit: false,
                isAuthEdit: isNoAuth('基金储备库-基金详情-编辑'),
                isAuthEditPre: isNoAuth('拟投资基金-基金详情-编辑'),
                registrationDetailed1: '', //注册地
                registrationDetailed2: '', //办公地
                fundReserveInfo: {
                    achievement: '', //业绩报酬
                    analysis: '', //行业分析
                    background: '', //设立背景
                    excitation: '', //激励约束
                    decision: '', //投资决策
                    distribution: '', //收益分配
                    expense: '', //管理费(%)
                    followOn: '', //跟进投资
                    fundId: '', //基金id
                    id: '', //主id
                    investmentDirection: '', //投资方向
                    investmentStage: '', // 投资阶段
                    organizationalForm: '', // 组织形式
                    other: '', // 其他
                    projectSelection: '', // 项目遴选
                    region: '', // 投资地域
                    regionList: [
                        {
                            businessId: '', //业务id
                            businessType: 1, //业务类型(1:注册地，2：办公地)
                            city: '', //市
                            district: '', //区
                            id: '',
                            province: '', //区
                            registrationDetailed: '' //详细地址
                        },
                        {
                            businessId: '', //业务id
                            businessType: 2, //业务类型(1:注册地，2：办公地)
                            city: '', //市
                            district: '', //区
                            id: '',
                            province: '', //区
                            registrationDetailed: '' //详细地址
                        }
                    ],
                    risk: '', // 风险控制
                    source: '', // 基金来源
                    trusteeship: '', // 资产托管
                },
            }
        },
        created() {
        },
        mounted() {
            this.getFundInfo()
            // 转拟投资添加小红点
            if (this.$route.params.turnInvest) {
                this.save()
            }
        },
        props: {

        },
        watch: {
        },
        methods: {
            async save() {
                this.showEdit = false
                await this.getFundInfo()
                // 添加小红点
                await addRemind({
                    dataId: this.$route.params.itemId, // 业务id
                    dataTab: 0, // tab页顺序 head 也为0 新建为'-1'
                    dataType: 4, // 1拟投资项目,2已投资项目,3母基金,4拟设立基金,5已设立基金,6客户,7潜在项目
                });
                // 根据第三方组件来调用 父组件中定义的方法 重新获取小红点
                this.$root.Dot.$emit('getDotList');
                // 添加小红点 end
            },
            getFundInfo() {
                apiHttp(api.CHECK_RESERVEINFO, {fundId: this.$route.params.itemId}).then(ret => {
                    if (ret.resCode === STATUS_HTTP_SUCCESS) {
                        this.fundReserveInfo = ret.data;
                        this.registrationDetailed1 = ''
                        this.registrationDetailed2 = ''
                        if (this.fundReserveInfo.regionList && this.fundReserveInfo.regionList.length !== 0) {
                            this.fundReserveInfo.regionList.map(item => {
                                if (item.businessType === 1) {
                                    this.registrationDetailed1 = item.registrationDetailed
                                } else if (item.businessType === 2) {
                                    this.registrationDetailed2 = item.registrationDetailed
                                }
                            })
                        }
                    }
                })
            },
        },
        components: {
            'csFundInfo': require('./edit'),//基金信息edit页
        },
    }
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.ca-right {
    float: right;
}
.el-break {
    word-wrap: break-word;
}
</style>